package com.hidt.shop.controller;

import com.hidt.shop.domain.Admin;
import com.hidt.shop.util.RestDate;
import org.springframework.web.bind.annotation.*;

/**
 * @author Fhy
 * @Title RestDemo
 * @Package com.hdit.shop.controller
 * @Description rest编码风格测试
 * @date 2021/2/21 15:21
 */
@RestController
public class RestDemo {
    @PutMapping("/putTest")
    public String putTest(String name,Integer age) {
        System.out.println(name);
        System.out.println(age);
        return "put success";
    }
    @DeleteMapping("/deleteTest")
    public String deleteTest(String name,Integer age) {
        System.out.println(name);
        System.out.println(age);
        return "delete success";
    }
    @PostMapping("/postTest")
    public String postTest(String name,Integer age) {
        System.out.println(name);
        System.out.println(age);
        return "post success";
    }
    @GetMapping("/getTest")
    public String getTest(String name,Integer age) {
        System.out.println(name);
        System.out.println(age);
        return "get success";
    }
    @GetMapping("/getTest2/{name}/{age}")
    public String getTest2(@PathVariable("name") String name, @PathVariable("age") Integer age) {
        System.out.println(name);
        System.out.println(age);
        return "get2 success";
    }
    @GetMapping("/getTest3/{name}/{age}")
    public RestDate<Admin> getTest3(@PathVariable("name") String name, @PathVariable("age") Integer age) {

        Admin admin = new Admin();
        admin.setAdmin_name(name);
        admin.setAdmin_pwd(name);
//        使用内部类会导致data数据无法找到
        RestDate<Admin> restDate = new RestDate<Admin>();
        restDate.setCode(200);
        restDate.setMess("OK");
        restDate.setData(admin);
        System.out.println(restDate);
        return restDate;
    }
}



